package com.huohuzhihui.web.controller.task;

import com.huohuzhihui.common.annotation.Log;
import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.core.page.TableDataInfo;
import com.huohuzhihui.common.enums.BusinessType;
import com.huohuzhihui.common.utils.poi.ExcelUtil;
import com.huohuzhihui.task.domain.TaskVideoMerge;
import com.huohuzhihui.task.service.ITaskVideoMergeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频合成记录Controller
 *
 * @author huohuzhihui
 * @date 2021-06-28
 */
@RestController
@RequestMapping("/task/taskVideoMerge")
public class TaskVideoMergeController extends BaseController {
    @Autowired
    private ITaskVideoMergeService taskVideoMergeService;

    /**
     * 查询视频合成记录列表
     */
    @PreAuthorize("@ss.hasPermi('task:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(TaskVideoMerge taskVideoMerge) {
        startPage();
        List<TaskVideoMerge> list = taskVideoMergeService.selectTaskVideoMergeList(taskVideoMerge);
        return getDataTable(list);
    }

    /**
     * 导出视频合成记录列表
     */
    @PreAuthorize("@ss.hasPermi('task:task:export')")
    @Log(title = "视频合成记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TaskVideoMerge taskVideoMerge) {
        List<TaskVideoMerge> list = taskVideoMergeService.selectTaskVideoMergeList(taskVideoMerge);
        ExcelUtil<TaskVideoMerge> util = new ExcelUtil<TaskVideoMerge>(TaskVideoMerge.class);
        return util.exportExcel(list, "task");
    }

    /**
     * 获取视频合成记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('task:task:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(taskVideoMergeService.selectTaskVideoMergeById(id));
    }

    /**
     * 新增视频合成记录
     */
    @PreAuthorize("@ss.hasPermi('task:task:add')")
    @Log(title = "视频合成记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TaskVideoMerge taskVideoMerge) {
        return toAjax(taskVideoMergeService.insertTaskVideoMerge(taskVideoMerge));
    }

    /**
     * 修改视频合成记录
     */
    @PreAuthorize("@ss.hasPermi('task:task:edit')")
    @Log(title = "视频合成记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TaskVideoMerge taskVideoMerge) {
        return toAjax(taskVideoMergeService.updateTaskVideoMerge(taskVideoMerge));
    }

    /**
     * 删除视频合成记录
     */
    @PreAuthorize("@ss.hasPermi('task:task:remove')")
    @Log(title = "视频合成记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(taskVideoMergeService.deleteTaskVideoMergeByIds(ids));
    }
}
